$(function () {
    $('.tomyJixie').click(function () {
        $(this).addClass('addjixie-active');
        $(this).siblings().removeClass('addjixie-active');
        $('.wrap-list').empty();
        $('.addjixe-article').addClass('hide');
        $('#myjixie-list-add').removeClass('hide');
        showLoad();
        RssApi.Table.List('zhaojixie').setLoading().condition({myid: RssUser.Data.myid, 'typeid': 2}).keymyid().getJson(function (data) {
            const json = data;
            let str = '';
            for (let i = 0; i < json.length; i++) {
                str+="<div class=\"jixie-list\">\n" +
                    "            <div>\n" +
                    "                <div>起重机械</div>\n" +
                    "                <div>品牌型号</div>\n" +
                    "                <div>所在位置</div>\n" +
                    "                <div>机械定位</div>\n" +
                    "                <div>GPS定位</div>\n" +
                    "                <div>车牌号</div>\n" +
                    "                <div>联系人</div>\n" +
                    "                <div>是否有合格证</div>\n" +
                    "                <div>联系电话</div>\n" +
                    "            </div>\n" +
                    "            <div>\n" +
                    "                <div>"+getClassfiyid(json[i].classifyid)+"</div>\n" +
                    "                <div>"+(getTrademarklid(json[i].trademarklid) === undefined ? getTrademarklid(json[i].trademarklid) : '暂无')+"</div>\n" +
                    "                <div>"+(json[i].location === undefined?'暂无' : json[i].location)+"</div>\n" +
                    "                <div>"+(json[i].machinerylocation === undefined?'暂无':json[i].machinerylocation)+"</div>\n" +
                    "                <div>"+(json[i].gpslocation === undefined? '暂无':json[i].gpslocation)+"</div>\n" +
                    "                <div>"+(json[i].platenumbers === undefined? '暂无': json[i].platenumbers)+"</div>\n" +
                    "                <div>"+json[i].linkman+"</div>\n" +
                    "                <div>是</div>\n" +
                    "                <div>"+json[i].telphone+"</div>\n" +
                    "            </div>\n" +
                    "        </div>\n" +
                    "        <div class=\"wrap-jixie-img\">\n" +
                    "            <div><img src="+(json[i].ico ? RssUpFile.getUrl(json[i].ico) : '')+"></div>\n" +
                    "        </div>\n" +
                    "        <div class=\"jixie-time\">\n" +
                    "            <div>"+formatTest(json[i].shijian)+"</div>\n" +
                    "            <div class=\"change\" onclick='toAddDetailTab("+json[i].id+")'>修改</div>\n" +
                    "        </div>"
            }
            $('.wrap-list').append(str);
        })
    })
    $('.tojixieList').click(function () {
        $(this).addClass('addjixie-active');
        $(this).siblings().removeClass('addjixie-active');
        $('.addjixe-article, #myjixie-list-add').addClass('hide');
        $('.jixieList').removeClass('hide');
        //getNeedList(2);
    })
    $('.toaddjxie').click(function () {
        $(this).addClass('addjixie-active');
        $(this).siblings().removeClass('addjixie-active');
        $('#myjixie-list-add, .jixieList').addClass('hide');
        $('.addjixe-article').removeClass('hide');
    })
})
function toAddDetailTab(id) {
    updateJixie(id);
    $('.toaddjxie').addClass('addjixie-active');
    $('.tomyJixie, .tojixieList').removeClass('addjixie-active');
    $('#myjixie-list-add, .jixieList').addClass('hide');
    $('.addjixe-article').removeClass('hide');
    $(".add-jixie-save").click(function () {
        RssApi.Table.Update('zhaojixie').setLoading().keyvalue($('#addjixie-form').serializeArray()).keyvalue('typeid', 2).condition({id: id}).keymyid().getJson(function (json) {
            console.info(json, 'json');
            if (json.id) {
                alert('修改成功');
                window.location.href='index.html';
            } else {
                alert('修改失败');
            }
        })
    })
}